This invention relates to mechanisms for facilitating communication between programs, or program segments, within a data processing system. More particularly, it relates to such a mechanism that is particularly useful in a small microprogrammed controller for facilitating the concurrent execution of two separate control programs.
In a data processing system, particularly that part of a system which is used as a controller for, for example, a plurality of input/output (I/O) devices, it may be necessary for the system to execute separate control programs substantially concurrently even though they may run at asynchronous rates. In order to accomplish this, there must be a mechanism for transferring control between the two programs.
A well known mechanism for accomplishing interaction between programs depends upon a hardware register which preserves, for a limited time, an indication of the memory address of an instruction in a program from which control was transferred. That instruction would typically be a (conditional or unconditional) branch instruction. If there would be a need to return control back to the original program, the contents of this register would have to be saved for subsequent utilization in returning. The saving of the contents of this register used storage (for the save instruction) and time (for the execution of the instruction) while accomplishing no other useful work.
Some of the disadvantages of the system described above were overcome in the 1960's by the provision of a computer instruction called "Branch And Link". This instruction was implemented by hardware which, in response to the instruction, caused a branch to a particular address specified by the instruction, and automatically stored in a "link register" an indication of the address from which control was transferred. Subsequently, the execution of another instruction called "Return" would cause control to be transferred to the instruction at the address indicated by the link register. Thus, a programmer was able very easily to cause the exiting from a main stream of coding to a sub-routine, and then return to the main stream, by using two simple instructions with no need to concern himself with storing the contents of any particular registers.
Although the combination of a Branch And Link and a Return instruction facilitated departure from a main line of programming to a sub-routine and back again, the simple transfer of control and return was uni-directional in the sense that these instructions could be used to go from program A to program B and back again but were of no help whatsoever in then again returning to program B at the point from which its execution was interrupted.
Another prior art approach, which may be combined with the above approaches, is to utilize interrupt mechanisms which respond to various predefined events (such as, for example, the status of an I/O device) by interrupting processing and causing a branch to a predefined address. The address may be (but need not be) related to the particular event that caused the interruption. Interrupt mechanisms, even in combination with the techniques described above, do not provide the ability to readily transfer control back and forth between programs. They do not automatically link back to the point of interruption in a program. An indication of the point of interruption is normally provided by programming. This wastes time. Also, the cost of implementing interrupt mechanisms militates against their use in very small controllers where cost is a significant factor.